package com.shushan.pages.newtype.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: StrangeWordsListBean
 * @Desciption: //生字列表bean
 * @author: zhangshihao
 * @date: 2018-07-23
 */
public class StrangeWordsListBean extends NetBaseBean {

    public int outline_id;
    public String outline_detail_name;
    public String outline_cover;
    public int outline_detail_id;
    public String press_name;
    public int state;

    public int progress_lock;
    public int paper_id;

    private List<NewWordBean> newWordBeans = new ArrayList<>();

    public int score;//获得时间奖励的分数
    public int time;//获得时间奖励的时间

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        progress_lock = jsonObject.optInt("progress_lock",0);
        paper_id = jsonObject.optInt("paper_id",0);

        JSONObject rewardObj = jsonObject.optJSONObject("reward");
        score = rewardObj.optInt("score",0);
        time = rewardObj.optInt("time",0);

        JSONObject subject = jsonObject.optJSONObject("subject");
        JSONObject chineseSbjInfo = subject.optJSONObject(Constants.SUBJECT_CHINESE_ID+"");
        if(chineseSbjInfo != null){
            outline_id = chineseSbjInfo.optInt("outline_id",0);
            outline_detail_name = chineseSbjInfo.optString("outline_detail_name","");
            outline_cover = chineseSbjInfo.optString("outline_cover","");
            outline_detail_id = chineseSbjInfo.optInt("outline_detail_id",0);
            press_name = chineseSbjInfo.optString("press_name","");
            state = chineseSbjInfo.optInt("state",1);
        }

        JSONArray newwordArr = jsonObject.optJSONArray("new_word");
        if(newwordArr != null && newwordArr.length() > 0){
            for(int i=0;i<newwordArr.length();i++){
                JSONObject obj = newwordArr.getJSONObject(i);
                NewWordBean bean = new NewWordBean();
                bean.initByJson(obj);
                newWordBeans.add(bean);
            }
        }
    }

    public List<NewWordBean> getNewWordBeans() {
        return newWordBeans;
    }

}
